home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
win1
/
martin10.zip
/
FRACT.TXT
< prev
next >
Wrap
Text File
|
1993-02-28
|
1KB
|
64 lines
Here is the heart of the Martin fractal code for those interested
//------------------------------------------------------------------
// InitSaver()
//------------------------------------------------------------------
void InitSaver(HWND hWnd)
{
a = double(random(100) - 50);
b = double(random(100) - 50);
c = double(random(100) - 50);
s = (abs(a) + abs(b) + abs(c)) / 3.0;
s = 6.0 - (abs(s/10.0));
ClearScreen(hWnd);
tc = 0;
xold = 0.0;
yold = 0.0;
};
//------------------------------------------------------------------
// Martin()
//------------------------------------------------------------------
void Martin(HWND hWnd)
{
static int t = 0;
static int clr = random(NumColor);
double xnew, ynew ;
if (t > tMax)
{
tc++;
t = 0;
clr = (clr+1) % NumColor;
};
Plot(hWnd, xold*s, yold*s, clr);
xnew = yold - Sign(xold)*sqrt(abs(b*xold-c));
ynew = a - xold;
xold = xnew ;
yold = ynew ;
t++;
}
//------------------------------------------------------------------
// SaverStep()
//------------------------------------------------------------------
void SaverStep(HWND hWnd)
{
if (tc > tcMax) InitSaver(hWnd);
Martin(hWnd);
};